package com.study.mall.mallproduct.controller;


import com.study.mall.mallproduct.entity.PmsBrand;
import com.study.mall.mallproduct.entity.PmsCategory;
import com.study.mall.mallproduct.service.PmsBrandService;
import com.stydy.mallcommon.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 品牌 前端控制器
 * </p>
 *
 * @author admin
 * @since 2022-03-05
 */
@RestController
@RequestMapping("/product/brand")
public class PmsBrandController {

    @Autowired
    private PmsBrandService pmsBrandService;
    //获取品牌列表
    @GetMapping("/list")
    public R list(){
        return R.ok().put("data",pmsBrandService.list());
    }
    //更新状态信息
    @PostMapping("/update/status")
    public R updateStatus(@RequestBody PmsBrand brand){
        this.pmsBrandService.saveOrUpdate(brand);
        return R.ok();
    }
    @DeleteMapping("/delete")
    public R delete(){
        return null;
    }
    @PostMapping("/info/{brandId}")
    public R info(@PathVariable("brandId") Long brandId){
        PmsBrand brands = this.pmsBrandService.getById(brandId);
        return R.ok().put("brand",brands);
    }

    @PostMapping("/add")
    public R add(@RequestBody PmsBrand pmsBrand){
        this.pmsBrandService.saveOrUpdate(pmsBrand);
        return R.ok();
    }
}

